        package Generic;

import java.util.*;

        public class Generic_homework2 {
    public static void main(String[] args) {
        ArrayList<String> poker = new ArrayList<>();
        poker.add("大王");
        poker.add("小王");
        String[] count = {"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
        String[] colour ={"♣","♦","♥","♠"};
        for (String s : count) {
            for (String s1 : colour) {
                poker.add(s+s1);
            }
        }
        Map<Integer,String> map = new HashMap<>();
        List<Integer> indexpoker = new ArrayList<>();
        for (int i = 0; i < 54; i++) {
            map.put(i,poker.get(i));
            indexpoker.add(i);
        }//用key的方法来作为牌的一个索引排序
        Collections.shuffle(indexpoker);
        //打乱索引集合
        System.out.println(indexpoker);
        ArrayList<Integer> player1 = new ArrayList<>();
        ArrayList<Integer> player2 = new ArrayList<>();
        ArrayList<Integer> player3 = new ArrayList<>();
        ArrayList<Integer> diPai = new ArrayList<>();
        for (int i = 0; i < 54; i++) {
            if(i>=51)
            {
                diPai.add(i);
            }
            else if(i%3==0)
            {
                player1.add(i);
            }
            else if(i%3==1)
            {
                player2.add(i);
            }
            else if(i%3==2)
            {
                player3.add(i);
            }
        }//发牌了
        Collections.sort(player1);
        Collections.sort(player2);
        Collections.sort(player3);
        Collections.sort(diPai);
        //对牌进行排序
        LookPai(player1,map,"王大");
        LookPai(player2,map,"王2");
        LookPai(player3,map,"王3");
        LookPai(diPai,map,"dipai");

    }
    public static void LookPai(ArrayList<Integer> pokerindex,Map<Integer,String> map,String name)
    {
        System.out.println("玩家"+name+"的牌为");
        for (Integer key:pokerindex)
        {
            System.out.print(map.get(key)+" ");
        }
        System.out.println();
    }
}
